const path = require("path")
module.exports = {
  entry: "./src/main.js",
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "./build"), // 必须是绝对路径
    // assetModuleFilename:"[name]-[hash][ext]"
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader",
          {
            loader:"postcss-loader",
          }
        ],
      },
      {
        test: /\.less$/,
        use: [
          { loader: "style-loader" },
          { loader: "css-loader" },
          { loader: "less-loader" },
        ],
      },
      {
        test:/\.(png|jpe?g|svg|gif)$/,
        // type:"asset/inline",
        // type:"asset/resource",
        type:"asset/resource",
        generator:{
          filename:"[name]_[hash:8][ext]"
        },
        parser:{
          dataUrlCondition:{
            maxSize:100*1024
          }
        }
      },
      {
        test:/\.js$/,
        use:[
          {
            loader:'babel-loader',
            options:{
              presets:[
                "@babel/preset-env"
              ]
            }
          }
        ]
      }
    ],
  },
};